clear; clc;

M = 2500;
N = 8000;
K = 10;
rate = 0.02;

% set number of threads
maxNumCompThreads(1);

for i = 1:5
    S = sprandn(M, N, rate);
    D = randn(N, K);
    
    t = tic;
    A1 = S*D;
    t1(i) = toc(t);

    S = full(S);
    t = tic;
    A2 = S*D;
    t2(i) = toc(t);
    
    S = sparse(S);
    [row, col, S] = find(S);
    [col, idx] = sort(col);
    row = row(idx);
    S = S(idx);
    A3 = zeros(M, K);
    t = tic;
    matProdSD(D, row, col, S, M, N, A3);
    t3(i) = toc(t);
    
    i
end

t1 = mean(t1);
t2 = mean(t2);
t3 = mean(t3);